export default {
	//开启命名空间
	namespaced: true,
	//数据
	state: () => ({
		//先到storage里面取，取不到就赋值为空对象
		address: JSON.parse(uni.getStorageSync('address')||'{}')
	}),
	//同步操作数据的方法
	mutations: {
		//修改地址的方法 
		udpAddress(state, address) {		
			state.address = address
			//拿到数据后，调用持久化存储的方法
			this.commit('m_user/saveAddressToStorage')
		},
		//持久化存储address
		saveAddressToStorage(state) {
			uni.setStorageSync('address', JSON.stringify(state.address))
		}
	},
	//数据包装器
	getters: {
     addrStr(state) {
     	if (!state.address.provinceName) return ''
     	return state.address.provinceName + state.address.cityName + state.address.countyName + state.address
     		.detailInfo
     }
	}
}
